using System;
using System.Xml.Serialization;
using System.Collections.Generic;
using System.Reflection;


namespace AppliedRecognition.Speech.QuickSwitch.serialization {

	[XmlRoot(Namespace="urn:Applied-Recognition:SpeechCommands", IsNullable=false)]
	public class SpeechCommandSet {
		public SpeechCommandSet() {
			Version =AssemblyVersion;
			menus = new List<SpeechMenuItem>();
		}

		public string AssemblyVersion {
			get { 
				Assembly asm = System.Reflection.Assembly.GetCallingAssembly();
				return asm.GetName().Version.ToString(2);
			}
		}
		
		private string name;
		[XmlAttribute()]	public string Name {
			get { return this.name; } set { this.name = value;}
		}

		private string version;
		[XmlAttribute()]public string Version {
			get { return this.version; } set { this.version = value;}
		}


		private List<SpeechMenuItem> menus;
		[XmlElement("Menu")]
        public List<SpeechMenuItem> Menus
        {
			get { return this.menus; } 
		}

		public override string ToString() {
			return Name;
		}

		public int NumCommands {
			get {
				int num=0;
				foreach (SpeechMenuItem smi in Menus) {
					num += smi.Commands.Count;
				}
				return num;
			}
		}
	}

}
